<?php

define("ROOT_PATH", "../");
#--------------------------------------------------
# ALL INCLUDES + STANDARD-VALUES
#--------------------------------------------------
include_once ("../include/author.php5");
include_once ("../include/config.inc");
include_once ("../include/template.inc");
include_once ("../include/class.db.php5");
include_once ("../include/class.tools.php5");
include_once ("../include/class.time.php5");
include_once ("./tools.php5");
include_once ("../dataAccess/classes/Schule.php5");
include_once ("../dataAccess/dao/SchuleDAO.php5");

$svo = new db("svoptik");
$tools = new tool();
$time = new TimeUtil();
include_once ("../include/global_fix_intern.inc");
#--------------------------------------------------
# CREATE TEMPLATE
#--------------------------------------------------
$t = new Template("templates", "keep");
$t->set_file(array (
	"page" => "svoptik.tpl",
	"navi" => "navi.tpl",
	"schulen" => "schulen.tpl"
));
#--------------------------------------------------

#--------------------------------------------------
# CREATE NAVIGATION RIGHT
#--------------------------------------------------
$links = "";
$url[0] = array (
	"URL" => "",
	"URL-TEXT" => "",
	"ONCLICK" => "",
	"TARGET" => "_self"
);
for ($i = 0; $i < count($url); $i++) {
	$links .= "
		        <tr height=\"15\">
					<td valign=\"top\"><img src=\"../standard/spacer.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"\"></td>
					<td valign=\"top\"><a href=\"" . $url[$i]['URL'] . "\" class=\"sitenav\" target=\"" . $url[$i]['TARGET'] . "\" onClick=\"" . $url[$i]['ONCLICK'] . "\">" . $url[$i]['URL-TEXT'] . "</a></td>
					<td valign=\"top\"><img src=\"../standard/spacer.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"\"></td>
				</tr>
				<tr height=\"15\">
		            <td colspan=\"3\"><img src=\"../standard/spacer.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"\"></td>
				</tr>
		       ";
}
include_once ("../member/standard/navi.php5");
$t->set_var(array (
	"LINKS" => $links,
	"BANNER" => $banner,
	"JSNAVI" => $js_navi
));
$right_nav = $t->parse("", "navi", true);
#--------------------------------------------------

#--------------------------------------------------
# CREATE CONTENT "schuleEN"
#--------------------------------------------------
if ($usr_priv > 0) {
	$dao = new SchuleDAO();
	$schulen = $dao->findAll();
	
	if ($schulen){
	$dscroll = dataScroller(count($schulen), 5, "start");
	
	for ($i = ($dscroll["from"] - 1); $i < $dscroll["to"]; $i++){
		$schule = $schulen[$i];	
		$foto = $schule->foto;
		if (!empty($foto) && strlen($foto) > 0){
			$foto = sprintf("<img src=\"%s\" border=\"0\" height=\"100\"/>", SCHULE_IMG_DIR.$foto);
		} else {
			$foto = "";
		}
		$t->set_var(array (
			"NAME" => $tools->html_replace($schule->name), 
			"STREET" => $tools->html_replace($schule->adr_street), 
			"CITY" => $tools->html_replace($schule->adr_plz)." ".$tools->html_replace($schule->adr_town),
			"TERMIN" => $tools->html_replace($schule->termin), 
			"HOMEPAGE" => $tools->html_replace($schule->homepage),
			"FOTO" => $foto,
			"EDIT_URL" => "schule_edit.php5?editId=".$schule->id,
			"DELETE_URL" => "schule_edit.php5?delId=".$schule->id));
		$content .= $t->parse("", "schulen", true);
	}
	
	// dataScroller Daten erzeugen
	include_once ("includes/dataScroller.php5");
	}
} else {
$content = "
  <script language=\"javascript\">
  <!--
  alert('Du besitzt leider nicht die erforderlichen Rechte,\\num diese Seite anzeigen zu lassen!');
  window.location.replace('index.php5');
  //-->
  </script>
  ";	
	
}

#--------------------------------------------------

#--------------------------------------------------
# PARSE & OUTPUT
#--------------------------------------------------
$t->set_var(array (
	"sitenav" => "MEMBERAREA -> SCHULEN",
	"content" => $content . "<br>",
	"navi" => $right_nav
));

$t->parse("ALL", "page", true);
$t->p("ALL");
?>
